<?php

abstract class App_Db_Model extends Zend_Db_Table_Abstract {  
	public $id;
	abstract function getArrayFromData($withkey=true);
	abstract function setDataFromArray($fieldArr);
	abstract function getDBArrayFromData($withkey=true);
	abstract function setDataFromDBArray($fieldArr);

    public function insert() {
    	$data = $this->getDBArrayFromData(false);
    	parent::insert($data);
    	$this->id = $this->lastInsertId();
    }
    
    public function update() {
    	$data = $this->getDBArrayFromData(false);
    	parent::update($data, 'id='.$this->id);
    }

    public function lastInsertId() {
    	return $this->getAdapter()->lastInsertId();
    }
}